#coding=utf-8 
from brownie import accounts, network, config, SimpleStorage;

def deploy_simple_storage():
    account = get_env();
    simple_storage = SimpleStorage.deploy({"from": account});
    initial_num = simple_storage.retrieve();
    print(f'initial number is {initial_num}');
    transaction = simple_storage.store(666);
    # 等待一个区块
    transaction.wait(1);
    updated_num = simple_storage.retrieve();
    print(f'updated num is {updated_num}');

# 根据部署环境确定使用的账号
def get_env():
    if (network.show_active() == 'development'):
        return accounts[0];
    else:
        return accounts.add(config['wallets']['from_key']);
def main():
    print(config);
    deploy_simple_storage();
